﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Windows.Forms;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Tuple<int, int, bool, bool, Dictionary<string, string>, int, int> tuple = ReadFile.ReadAllFile(); //Tuple<k, n, isStemm, toSort?, Dic<fileName, textOfFile>, featureSelection, docsFromEachCluster, numOfPairsForExpert>>
            if (tuple == null)
                return;
            Parser parser = new Parser(tuple.Item3);
            //Parser.ProcessFiles(tuple.Item5);

            DBClass DB = new DBClass();
            DB.CreateAllDocuments(Parser.ProcessFiles(tuple.Item5), tuple.Item1, tuple.Item2, tuple.Item4);
            DB.CreateTfIdf(tuple.Item6);

            UserDomain u = new UserDomain(3.4);
            Document d1 = DB.allDocuments[0];
            Document d2 = DB.allDocuments[2];
            u.m_myDocuments.Add(DB.allDocuments[4], DB.allDocuments[4].m_fingerPrints.Count);
            u.m_myDocuments.Add(DB.allDocuments[7], DB.allDocuments[7].m_fingerPrints.Count);
            u.m_myDocuments.Add(DB.allDocuments[1], DB.allDocuments[1].m_fingerPrints.Count);
            u.m_myDocuments.Add(DB.allDocuments[3], DB.allDocuments[3].m_fingerPrints.Count);
            u.ContentsPercent(d1);

            ClustersGenerator cg = new ClustersGenerator();

            Dictionary<int, List<string>> allClusters = new Dictionary<int, List<string>>();
            allClusters = cg.GenerateClusters(DB.tfidfDic, DB.topNgrams);
            
            DomainExpert dE = new DomainExpert();
            Dictionary<string, int> clustersForExpert = new Dictionary<string, int>();
            clustersForExpert = dE.SelectRandomDocumentsFromClusters(allClusters, tuple.Item7);
            Dictionary<KeyValuePair<string, string>, double> result = dE.CreatePairsOfDocs(clustersForExpert, 10);
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new mainForm(result, tuple.Item5));
        }
    }
}
